import { Form, Layout, Select } from "antd";
import AvatarIcon from "./components/AvatarIcon";
import CollapseIcon from "./components/CollapseIcon";
import BreadcrumbNav from "./components/BreadcrumbNav";
import AssemblySize from "./components/AssemblySize";
import Language from "./components/Language";
import Theme from "./components/Theme";
import Fullscreen from "./components/Fullscreen";
import "./index.less";
import { AdminEntitySelect } from "@/components";

import {
	lsSetItem,
} from '@/utils/util'
import { useAppSelector } from "@/utils/hooks";



const LayoutHeader = () => {
	const { Header } = Layout;
	const [form] = Form.useForm()
	const [app] = useAppSelector(state => [state.app])
	const { userInfo } = app


	return (
		<Header>
			<div className="header-lf">
				<CollapseIcon />
				<BreadcrumbNav />
			</div>
			<div className="header-ri">
				<div>
				<Form layout="inline" form={form}>
				<AdminEntitySelect
					key={'entityId'}
					formItemProps={{
						name: 'entityId',
						// style: { display: currentPath.isPatrolCenter ? 'none' : '' },
					}}
					childProps={{
						dropdownMatchSelectWidth: false,
						allowClear: false,
						style: { width: 150 },
						dropdownStyle: { maxHeight: 400, overflow: 'auto' },
						// className: classnames({
						// 	'custom-select': isBigScreenCenter,
						// 	'custom-select-header': isBigScreenCenter,
						// 	'subway-custom-select': isSubwayOrPatrol,
						// }),
						popupClassName: 'custom-select-dropdown',
						// @ts-ignore
						onChange(id, entity: Entity) {
							lsSetItem('__entityId__', id)
							// 判断searchParams.businessType是否有效
							// const searchBizType = +(searchParams.businessType as string)
							// const isValidBiz =
							// 	entity.entityBusinessType === businessLineMap.double
							// 		? searchBizType <= entity.entityBusinessType
							// 		: searchBizType === entity.entityBusinessType
							// if (entity.fromSearch && isValidBiz) {
							// 	form.setFieldsValue({ bizType: searchBizType })
							// 	handleBizChange(searchBizType as any)
							// } else {
							// 	form.setFieldsValue({ bizType: selectBizFromBizType(entity.entityBusinessType) })
							// 	handleBizChange(entity.entityBusinessType)
							// }
							// if (showSearchSelect) {
							// 	searchSelectRef.current?.setOptions([])
							// 	form.setFieldValue('fenceId', undefined)
							// 	dispatch(currentFence({ fenceId: undefined, selectFenceId: undefined }))
							// }
						},
					}}
					extraProps={{ form }}
				></AdminEntitySelect>
				</Form>
				</div>

				<AssemblySize />
				<Language />
				<Theme />
				<Fullscreen />
				<span className="username">{userInfo.userName}</span>
				<AvatarIcon />
			</div>
		</Header>
	);
};

export default LayoutHeader;
